# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=git-lfs
pkgver=3.4.0
pkgrel=1
pkgdesc="Git extension for versioning large files"
arch=('loong64' 'x86_64' 'aarch64')
url="https://git-lfs.github.com"
license=('MIT')
makedepends=('go' 'ruby-ronn' 'go-tools' 'asciidoctor')
depends=('git')
source=("git+https://github.com/git-lfs/git-lfs.git#tag=v${pkgver}?signed")
validpgpkeys=('88ACE9B29196305BA9947552F1BA225C0223B187'  # brian m. carlson <sandals@crustytoothpaste.net>
              '86CD3297749375BCF8206715F54FE648088335A9') # Chris Darroch (CODE SIGNING KEY) <chrisd@apache.org>
sha256sums=('SKIP')

build(){
  cd "$pkgname"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -modcacherw -ldflags=-linkmode=external"
  go mod vendor
  go generate ./commands
  go build .
  make man
}

check(){
  cd "$pkgname"
  go test -mod=vendor ./...
}

package() {
  cd "$pkgname"
  install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
  install -Dm644 LICENSE.md "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  install -Dm644 -t "$pkgdir"/usr/share/man/man1 man/man1/*.1
  install -Dm644 -t "$pkgdir"/usr/share/man/man5 man/man5/*.5
}
